package com.cbs.android.component.runtimecache;

import java.util.Observable;

/**
 * Created by brochexu on 4/14/14.
 */
public abstract class RuntimeCacheItem extends Observable {
    public final static int DataType_Boolean = 1;
    public final static int DataType_Float = 2;
    public final static int DataType_Int = 3;
    public final static int DataType_Long = 4;
    public final static int DataType_String = 5;
    public final static int DataType_Object = 6;

    private Object value;

    public abstract Object getDefaultValue();

    public abstract int getDataType();

    public Object decode(String svalue) {
        return new Object();
    }

    public String encode(Object ovalue) {
        return "";
    }

    public abstract boolean isSave();

    public abstract boolean isNotify();


    public RuntimeCacheItem() {
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public void reset() {
        this.value = getDefaultValue();
    }

    public void notifyObs() {
        setChanged();
        notifyObservers(value);
    }
}
